package com.bff.gaia.unified.sdk.transforms.xjoin.client.rdb.utils;



import com.bff.gaia.unified.sdk.schemas.Schema;

import com.bff.gaia.unified.sdk.values.Row;



import java.util.ArrayList;

import java.util.List;



public class ProjectUitl {

	static public Row projectRow(Row row, int[] fields) {

		List<Schema.Field> fieldList = row.getSchema().getFields();

		List<Schema.Field> targetFieldList = new ArrayList<>();

		List<Object> objectList=row.getValues();

		List<Object> targetObjectList=new ArrayList<>();

		for (int i : fields) {

			targetFieldList.add(fieldList.get(i));

			targetObjectList.add(objectList.get(i));

		}

		return Row.withSchema(new Schema(targetFieldList)).addValues(targetObjectList).build();

	}

}